﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "AddPlatformPages.h"
#include "GbmpUiPlatformCommandIds.h"
#include "GcmpCommandNames.h"
#include "GbmpUiPlatformCommandIds.h"
#include "GbmpControlIds.h"
#include "GcmpCommandState.h"
#include "GmGbmpUiConfigurationCommandRegister.h"
#include "IPublishConfig.h"

#include "IRibbon.h"
#include "IRibbonPage.h"
#include "IRibbonGroup.h"
#include "IApplication.h"
#include "IMainWindow.h"
#include "ICommandButtonDefinition.h"
#include "ICommandButtonMenuDefinition.h"
#include "ICommandMenuItemDefinition.h"
#include "IPageHandler.h"
#include "GcmpDebugCommandNames.h"
#include "IAddinManager.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"


using namespace gcmp;

namespace
{
    class gbmpViewPageHandler : public IPageHandler
    {
    public:
        gbmpViewPageHandler() {}
        virtual ~gbmpViewPageHandler() {}

    public:
       
        virtual bool IsVisible() const override
        {
            return GcmpCommandState::IsInProjectEnvironment() && !GcmpCommandState::IsInAnimationEnvironment();
        }
        virtual bool IsEnabled() const override
        {
            return true;
        }
    };
}

void AddPlatformPages::AddPageGbmpView()
{
    OwnerPtr<IRibbonPage> opPage = IRibbonPage::Create(ID_PAGE_GBMP_VIEW, GBMP_TR(L"视图"));
    DBG_WARN_AND_RETURN_VOID_UNLESS(opPage, L"opPage为空",L"GDMPLab",L"2024-03-30");
    opPage->SetPageHandler(TransferOwnership(NEW_AS_OWNER_PTR(gbmpViewPageHandler)));
    //视图创建
    {
        const std::wstring groupId = L"gbmpViewGroup";
        OwnerPtr<IRibbonGroup> opGroup = IRibbonGroup::Create(groupId, GBMP_TR(L"视图创建"));
        DBG_WARN_AND_RETURN_VOID_UNLESS(opGroup, L"opGroup为空",L"GDMPLab",L"2024-03-30");

        {
            // 平面视图
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_GBMP_CREATE_PLAN_VIEW, GBMP_TR(L"平面视图"), GBMP_TR(L"平面视图"), ID_CMD_GBMP_CREATE_PLAN_VIEW, L":/images/view/平面视图.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        // 立面视图-暂时与旧版采用同一命令
        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_CREATE_ELEVATION_VIEW, GBMP_TR(L"String_Create_View_Elevation"), GBMP_TR(L"String_Create_View_Elevation"), ID_CMD_CREATE_ELEVATION_VIEW, L":/images/view/立面视图.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        {
            // 三维视图
            const std::wstring buttonMenuId = L"gbmp3DViewMenu";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, ID_CMD_GBMP_CREATE_3D_VIEW, GBMP_TR(L"三维视图"), L":/images/view/三维视图.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_GBMP_CREATE_3D_VIEW, ID_CMD_GBMP_CREATE_3D_VIEW, GBMP_TR(L"创建三维视图"), GBMP_TR(L"创建三维视图"), L":/images/view/三维视图.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }
            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }
        {
            // 剖面视图
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_GBMP_CREATE_SECTION_VIEW, GBMP_TR(L"剖面视图"), GBMP_TR(L"剖面视图"), ID_CMD_GBMP_CREATE_SECTION_VIEW, L":/images/view/剖面视图.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        {
            // 阶梯视图
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_GBMP_CREATE_STAIR_VIEW, GBMP_TR(L"阶梯视图"), GBMP_TR(L"阶梯视图"), ID_CMD_GBMP_CREATE_STAIR_VIEW, L":/images/view/剖面视图.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }


        opPage->AddGroup(TransferOwnership(opGroup));
    }
    // 图形Group-暂时与旧版采用同一命令
    {
        const std::wstring groupId(L"gmStyleGroup");
        OwnerPtr<IRibbonGroup> opGroup = IRibbonGroup::Create(groupId, GBMP_TR(L"图形"));
        DBG_WARN_AND_RETURN_VOID_UNLESS(opGroup, L"opGroup为空",L"GDMPLab",L"2024-03-30");

        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_VIEW_GRAPHICS_STYLE, GBMP_TR(L"视图\n对象样式"), GBMP_TR(L"视图\n对象样式"), ID_CMD_VIEW_GRAPHICS_STYLE, L":/images/view/视图样式01.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_TEMPORARY_HIDE_SELECTION, GBMP_TR(L"隐藏所选"), GBMP_TR(L"隐藏所选"), ID_CMD_TEMPORARY_HIDE_SELECTION, L":/images/view/隐藏所选.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_TEMPORARY_HIDE_OTHER, GBMP_TR(L"隐藏其他"), GBMP_TR(L"隐藏其他"), ID_CMD_TEMPORARY_HIDE_OTHER, L":/images/view/隐藏其他.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_RESET_TEMPORARY_HIDDEN_ELEMENTS, GBMP_TR(L"重置隐藏"), GBMP_TR(L"重置隐藏"), ID_CMD_RESET_TEMPORARY_HIDDEN_ELEMENTS, L":/images/view/重置隐藏.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        opPage->AddGroup(TransferOwnership(opGroup));
    }
    // 窗口Group-暂时与旧版采用同一命令
    {
        const std::wstring groupId(L"gmWindowGroup");
        OwnerPtr<IRibbonGroup> opGroup = IRibbonGroup::Create(groupId, GBMP_TR(L"窗口"));
        DBG_WARN_AND_RETURN_VOID_UNLESS(opGroup, L"opGroup为空",L"GDMPLab",L"2024-03-30");

        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_ZOOM_FIT, GBMP_TR(L"缩放匹配"), GBMP_TR(L"缩放匹配"), ID_CMD_ZOOM_FIT, L":/images/view/缩放匹配.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_TILE_WINDOW, GBMP_TR(L"平铺视窗"), GBMP_TR(L"平铺视窗"), ID_CMD_TILE_WINDOW, L":/images/view/平铺窗口.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        opPage->AddGroup(TransferOwnership(opGroup));
    }
    // 界面Group-暂时与旧版采用同一命令
    {
        const std::wstring groupId(L"gmUISettingGroup");
        OwnerPtr<IRibbonGroup> opGroup = IRibbonGroup::Create(groupId, GBMP_TR(L"界面"));
        DBG_WARN_AND_RETURN_VOID_UNLESS(opGroup, L"opGroup为空",L"GDMPLab",L"2024-03-30");

        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_SHOW_HIDE_VIEWMANAGER, GBMP_TR(L"视图\n管理器"), GBMP_TR(L"视图\n管理器"), ID_CMD_SHOW_HIDE_VIEWMANAGER, L":/images/view/视图管理器.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        {
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_SHOW_HIDE_PROPERTY_PALETTE, GBMP_TR(L"属性面板"), GBMP_TR(L"属性面板"), ID_CMD_SHOW_HIDE_PROPERTY_PALETTE, L":/images/view/属性面板.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }
        opPage->AddGroup(TransferOwnership(opGroup));
    }

    IRibbon* pRibbon = IMainWindow::GetMainWindow()->GetRibbon();
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRibbon, L"pRibbon为空",L"GDMPLab",L"2024-03-30");

    pRibbon->AddPage(TransferOwnership(opPage));
}

bool AddPlatformPages::ToShowDevTools()
{
    IAddinManager* pAddinManager = IAddinManager::Get();
    if (nullptr == pAddinManager)
    {
        return false;
    }
    std::vector<std::wstring> addinIds = pAddinManager->GetAllAddinIds();
    if (addinIds.empty())
    {
        return false;
    }
    for (auto& id : addinIds)
    {
        if (id.compare(L"GcmpDebug") == 0)
        {
            return true;
        }
    }
    return false;
}

void AddPlatformPages::AddPageDevTools()
{
    if (!ToShowDevTools())
    {
        return;
    }
    OwnerPtr<IRibbonPage> opPage = IRibbonPage::Create(ID_PAGE_GBMP_DEVTOOLS, GBMP_TR(L"开发工具"));
    DBG_WARN_AND_RETURN_VOID_UNLESS(opPage, L"opPage为空",L"GDMPLab",L"2024-03-30");
    {
        const std::wstring groupId(L"gmUIDevTools");
        OwnerPtr<IRibbonGroup> opGroup = IRibbonGroup::Create(groupId, GBMP_TR(L"开发工具"));
        DBG_WARN_AND_RETURN_VOID_UNLESS(opGroup, L"opGroup为空",L"GDMPLab",L"2024-03-30");
        {
            // Debug Mode
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_SET_DEBUG_MODE, GBMP_TR(L"Debug Mode"), GBMP_TR(L"Debug Mode"), ID_CMD_SET_DEBUG_MODE, L":/images/Test/48x48.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        {
            // Regression Test
            const std::wstring buttonMenuId = L"Regression Test";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"Regression Test"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_REPLAY_JOURNAL, ID_CMD_REPLAY_JOURNAL, GBMP_TR(L"日志回放(脚本文件)"), GBMP_TR(L"日志回放(脚本文件)"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_REPLAY_JOURNAL_CONTENT, ID_CMD_REPLAY_JOURNAL_CONTENT, GBMP_TR(L"日志回放(js语句块)"), GBMP_TR(L"日志回放(js语句块)"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_CONTINUOUS_REPLAY_JOURNAL, ID_CMD_CONTINUOUS_REPLAY_JOURNAL, GBMP_TR(L"循环日志回放(脚本文件)"), GBMP_TR(L"循环日志回放(脚本文件)"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_UNIT_TEST, ID_CMD_UNIT_TEST, GBMP_TR(L"Unit Test"), GBMP_TR(L"Unit Test"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_API_TEST, ID_CMD_API_TEST, GBMP_TR(L"GUnit Runner"), GBMP_TR(L"GUnit Runner"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }

        {
            // 日志验证器
            const std::wstring buttonMenuId = L"日志验证器";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"日志验证器"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_MODEL_VALIDATOR, ID_CMD_MODEL_VALIDATOR, GBMP_TR(L"添加验证器"), GBMP_TR(L"添加验证器"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_SNAPSHOT_VALIDATOR, ID_CMD_SNAPSHOT_VALIDATOR, GBMP_TR(L"截图比对"), GBMP_TR(L"截图比对"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }

        {
            // Runtime Information
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_RUNTIME_INFO, GBMP_TR(L"Runtime Information"), GBMP_TR(L"Runtime Information"), ID_CMD_RUNTIME_INFO, L":/images/Test/48x48.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        {
            // Dump
            const std::wstring buttonMenuId = L"Dump";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"Dump"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DUMP_ALL_ELEMENTS, ID_CMD_DUMP_ALL_ELEMENTS, GBMP_TR(L"All Elements"), GBMP_TR(L"All Elements"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_FIX_SHORT_ELEMENTID, ID_CMD_FIX_SHORT_ELEMENTID, GBMP_TR(L"Fix Short Id"), GBMP_TR(L"Fix Short Id"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DUMP_ANCESTORS_OF_SELECTED_AS_PNG, ID_CMD_DUMP_ANCESTORS_OF_SELECTED_AS_PNG, GBMP_TR(L"Dump Ancestors of Selection"), GBMP_TR(L"Dump Ancestors of Selection"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DUMP_CHILDREN_OF_SELECTED, ID_CMD_DUMP_CHILDREN_OF_SELECTED, GBMP_TR(L"Dump Children of Selection"), GBMP_TR(L"Dump Children of Selection"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DUMP_DECENDANTS_OF_SELECTED_AS_DOT, ID_CMD_DUMP_DECENDANTS_OF_SELECTED_AS_DOT, GBMP_TR(L"Dump Decendants of Selection"), GBMP_TR(L"Dump Decendants of Selection"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DUMP_OBJECT_RELATIONSHIPS_OF_SELECTED_AS_DOT, ID_CMD_DUMP_OBJECT_RELATIONSHIPS_OF_SELECTED_AS_DOT, GBMP_TR(L"Dump Relationships of Selection"), GBMP_TR(L"Dump Relationships of Selection"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DUMP_CURRENT_CLASS_SCHEMAS_AS_XML, ID_CMD_DUMP_CURRENT_CLASS_SCHEMAS_AS_XML, GBMP_TR(L"导出ClassSchemas为XML格式"), GBMP_TR(L"导出ClassSchemas为XML格式"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }

        {
            // GRep
            const std::wstring buttonMenuId = L"GRep";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"GRep"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_GREP_TO_JSON, ID_CMD_GREP_TO_JSON, GBMP_TR(L"Dump GRep As Json"), GBMP_TR(L"Dump GRep As Json"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_CREATE_GREP_FROM_JSON, ID_CMD_CREATE_GREP_FROM_JSON, GBMP_TR(L"Create GRep From Json"), GBMP_TR(L"Create GRep From Json"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_GREP_TO_JSON_AND_FROM_JSON, ID_CMD_GREP_TO_JSON_AND_FROM_JSON, GBMP_TR(L"Dump GRep As Json And From JSON"), GBMP_TR(L"Dump GRep As Json And From JSON"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }

        {
            // 收集文档中需要升级的类信息
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_COLLECT_NEED_UPGRADE_CLASSID, GBMP_TR(L"收集文档中需要升级的类信息"), GBMP_TR(L"收集文档中需要升级的类信息"), ID_CMD_COLLECT_NEED_UPGRADE_CLASSID, L":/images/Test/48x48.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        {
            // Ndb对象创建情况
            const std::wstring buttonMenuId = L"Ndb对象创建情况";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"Ndb对象创建情况"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_BEGIN_NDB_ELEMENT_CREATION_STATS, ID_CMD_BEGIN_NDB_ELEMENT_CREATION_STATS, GBMP_TR(L"开始统计"), GBMP_TR(L"开始统计"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_END_NDB_ELEMENT_CREATION_STATS, ID_CMD_END_NDB_ELEMENT_CREATION_STATS, GBMP_TR(L"结束统计（在Dump文件里）"), GBMP_TR(L"结束统计（在Dump文件里）"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }

        {
            // Select By-Id
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_SELECT_BY_ID, GBMP_TR(L"Select By-Id"), GBMP_TR(L"Select By-Id"), ID_CMD_SELECT_BY_ID, L":/images/Test/48x48.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        {
            // Pick
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_PICK_4_DEVELOPER, GBMP_TR(L"Pick"), GBMP_TR(L"Pick"), ID_CMD_PICK_4_DEVELOPER, L":/images/Test/48x48.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        {
            // Reload Existing Families(From temp file other than user's file)
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_RELOAD_FAMILIES, GBMP_TR(L"Reload Existing Families(From temp file other than user's file)"), GBMP_TR(L"Reload Existing Families(From temp file other than user's file)"), ID_CMD_RELOAD_FAMILIES, L":/images/Test/48x48.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        {
            // Save Elements By Category
            OwnerPtr<ICommandButtonDefinition> opButtonDef = ICommandButtonDefinition::Create(ID_CMD_SAVE_ELEMENTS_BY_CATEGORY, GBMP_TR(L"Save Elements By Category"), GBMP_TR(L"Save Elements By Category"), ID_CMD_SAVE_ELEMENTS_BY_CATEGORY, L":/images/Test/48x48.png");
            opGroup->AddButton(TransferOwnership(opButtonDef));
        }

        {
            // Regen
            const std::wstring buttonMenuId = L"Regen";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"Regen"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_REGENERATE_ALL, ID_CMD_REGENERATE_ALL, GBMP_TR(L"Force Regen Project Doc"), GBMP_TR(L"Force Regen Project Doc"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_REGENERATE_Project_And_Family_DOCMENTS, ID_CMD_REGENERATE_Project_And_Family_DOCMENTS, GBMP_TR(L"Force Regen Project And Family Docs"), GBMP_TR(L"Force Regen Project And Family Docs"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_REGENERATE_SELECTED, ID_CMD_REGENERATE_SELECTED, GBMP_TR(L"Force Regen Selected"), GBMP_TR(L"Force Regen Selected"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }

        {
            // RelationShip
            const std::wstring buttonMenuId = L"RelationShip";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"RelationShip"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_ELIMINATE_CUT_RELATIONSHIP, ID_CMD_ELIMINATE_CUT_RELATIONSHIP, GBMP_TR(L"Eliminate Cut Relationship"), GBMP_TR(L"Eliminate Cut Relationship"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_ELIMINATE_JOIN_RELATIONSHIP, ID_CMD_ELIMINATE_JOIN_RELATIONSHIP, GBMP_TR(L"Eliminate Join Relationship"), GBMP_TR(L"Eliminate Join Relationship"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }
        if(false) //TODO:等有链接功能后添加
        {
            // 链接
            const std::wstring buttonMenuId = L"链接";
            OwnerPtr<ICommandButtonMenuDefinition> opButtonMenuDef = ICommandButtonMenuDefinition::Create(buttonMenuId, buttonMenuId, GBMP_TR(L"链接"), L":/images/Test/48x48.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opButtonMenuDef, L"opButtonMenuDef为空",L"GDMPLab",L"2024-03-30");

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DELETE_UNLOADED_LINK_DOCUMENT_TYPE, ID_CMD_DELETE_UNLOADED_LINK_DOCUMENT_TYPE, GBMP_TR(L"删除未连接状态的链接文档类型对象"), GBMP_TR(L"删除未连接状态的链接文档类型对象"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }

            {
                OwnerPtr<ICommandMenuItemDefinition> opMenuItem = ICommandMenuItemDefinition::Create(ID_CMD_DELETE_UNRECORDED_PROXIES, ID_CMD_DELETE_UNRECORDED_PROXIES, GBMP_TR(L"删除未被记录的代理对象"), GBMP_TR(L"删除未被记录的代理对象"), L":/images/Test/48x48.png");
                opButtonMenuDef->AddItem(TransferOwnership(opMenuItem));
            }
            opGroup->AddButtonMenu(TransferOwnership(opButtonMenuDef));
        }
        opPage->AddGroup(TransferOwnership(opGroup));
    }
    IRibbon* pRibbon = IMainWindow::GetMainWindow()->GetRibbon();
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRibbon, L"pRibbon为空",L"GDMPLab",L"2024-03-30");
    pRibbon->AddPage(TransferOwnership(opPage));
}


